package com.itheima.mapper;

import com.itheima.dto.ClazzQueryParam;
import com.itheima.pojo.Clazz;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClazzMapper {

//    @Results({
//            @Result(column = "begin_data",property = "beginDate"),
//            @Result(column = "end_date",property = "endDate"),
//            @Result(column = "master_id",property = "masterId"),
//            @Result(column = "create_time",property = "createTime"),
//            @Result(column = "update_time",property = "updateTime"),
//    })

    @Insert("insert into clazz (name,room,begin_date,end_date,master_id,subject,create_time,update_time) values (#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    Integer add(Clazz clazz);

    @Select("select * from clazz")
    List<Clazz> findALl();

    List<Clazz> list(ClazzQueryParam clazzQueryParam);

    @Delete("delete from clazz where id = #{id}")
    void deleteById(Integer id);

    @Select("select * from clazz where id = #{id}")
    Clazz getById(Integer id);

    @Update("update clazz set name=#{name},room=#{room},begin_date=#{beginDate},end_date=#{endDate},master_id=#{masterId},subject=#{subject},update_time=#{updateTime} where id = #{id}")
    void update(Clazz clazz);
}
